package com.taowan.xunbaozl.morning_speak.design_pattern.day01;

/**
 * @author ygh
 * @date 2016/02/22
 * @title 单例模式
 */
public class SingleTon {

    private static SingleTon instance;


    public static SingleTon getInstance() {
        /**
         * 这里判断，排除大部分情况，不进synchronized 代码，提升效率
         */
        if (instance == null) {
            synchronized (SingleTon.class) {
                if (instance == null) {
                    instance = new SingleTon();
                }
            }
        }
        return instance;
    }
}
